﻿using CefDemo.cef;
using CefSharp;
using System;
using System.IO;
using System.Windows.Forms;

namespace CefDemo
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            InitializeCefSetting();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }

        public static void InitializeCefSetting()
        {
            var cefResoucePath = Path.Combine(Application.StartupPath, @"Cef");
            CefBootstrap.InitCef(settings =>
            {
                settings.Locale = "zh-CN";
                //以下两行代码是设置Cef资源包的路径，如果没有更改资源包路径，可以注释
                settings.LocalesDirPath = cefResoucePath + @"\locales";
                settings.BrowserSubprocessPath = cefResoucePath + @"\CefSharp.BrowserSubprocess.exe";

                settings.RegisterScheme(new CefCustomScheme()
                {
                    SchemeName = ResourceSchemeHandlerFactory.SchemeName,
                    SchemeHandlerFactory = new ResourceSchemeHandlerFactory()
                });
            });
        }

    }
}
